package com.zqh.myfmmall.rowbeans.vo;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.zqh.myfmmall.rowbeans.entity.ProductComments;
import com.zqh.myfmmall.rowbeans.entity.Users;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProductCommentsVO {

    private String commId;
    private String productId;
    private String productName;
    private String orderItemId;
    private Integer isAnonymous;
    private Integer commType;
    private String commContent;
    private String commImgs;
    private LocalDateTime createTime;
    private Integer replyStatus;
    private String replyContent;

//    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
//    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime replyTime;
    private Integer isShow;
    //封装评论对应的用户数据
    private String userId;
    private String username;
    private String nickname;
    private String userImg;

    public ProductCommentsVO(ProductComments productComments, Users user){
        this.commId = productComments.getCommId();
        this.productId = productComments.getProductId();
        this.productName = productComments.getSkuProps();
        this.orderItemId = productComments.getOrderItemId();
        this.isAnonymous = productComments.getIsAnonymous();
        this.commType = productComments.getCommType();
        this.commContent = productComments.getCommContent();
        this.commImgs = productComments.getCommImgs();
        this.createTime = productComments.getCreateTime();
        this.replyStatus = productComments.getReplyStatus();
        this.replyContent = productComments.getReplyContent();
        this.replyTime = productComments.getReplyTime();
        this.isShow = productComments.getIsShow();
        this.userId = user.getUserId();
        this.username = user.getUsername();
        this.nickname = user.getNickname();
        this.userImg = user.getUserImg();
    }
}